//
// TransversityProkudin.cxx
//
// Created by TB on 11/23/11.
// Copyright 2011 BNL. All rights reserved.
//

#include <boost/foreach.hpp>

#include "tppmc/Particle.h"
#include "tppmc/PartonContent.h"
#include "tppmc/TransversityProkudin.h"

namespace tppmc {
   
   //
   // class TransversityProkudin
   //
   
   
   TransversityProkudin::TransversityProkudin(int order)
   : mBound(order) {
      
      // Initialise parameters
      mParameters.SetReadFile("tables/transversity_parameters.dat");
      mParameters.ReadParameters();
      mParameters.UseMainSet();
   }
   
   
   TransversityProkudin::~TransversityProkudin() {
   }

   void TransversityProkudin::Evaluate(const pythpart& parton, double Q2,
                                       PartonContent& partcontent) const {
      // Evaluate the Soffer bound:
      mBound.Evaluate(parton, Q2, partcontent);
      
      // Light quark flavours are supported:
      int flavours[] = {
         LHAPDF::UP, LHAPDF::DOWN, LHAPDF::STRANGE,
         LHAPDF::UBAR, LHAPDF::DBAR, LHAPDF::SBAR
      };
      
      // Set values for light quarks
      BOOST_FOREACH(int flavour, flavours) {
         const FitValues* fit = mParameters.parameters.Values(flavour);
         if(not fit) continue;
         
         partcontent[flavour] *= fit->EvaluateTransversity(parton);
      } // BOOST_FOREACH
   }
   
   
   bool TransversityProkudin::Supports(const pythpart& parton) const {
      // Light quarks only
      return ::abs(parton.Pdg()) < 4;
   }
}
